home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / debugger / ddd-1.000 / ddd-1 / ddd-1.4b / vsllib / tree.vsl < prev    next >
Encoding:
Text File  |  1995-05-17  |  3.3 KB  |  118 lines

  1. // $Id: tree.vsl,v 1.2 1995/05/17 13:40:01 zeller Exp $
  2. // Draw trees
  3.  
  4. // Copyright (C) 1993 Technische Universitaet Braunschweig, Germany.
  5. // Written by Andreas Zeller (zeller@ips.cs.tu-bs.de).
  6. // 
  7. // This file is part of the NORA Library.
  8. // 
  9. // The NORA Library is free software; you can redistribute it and/or
  10. // modify it under the terms of the GNU Library General Public
  11. // License as published by the Free Software Foundation; either
  12. // version 2 of the License, or (at your option) any later version.
  13. // 
  14. // The NORA Library is distributed in the hope that it will be useful,
  15. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  17. // See the GNU Library General Public License for more details.
  18. // 
  19. // You should have received a copy of the GNU Library General Public
  20. // License along with the NORA Library -- see the file COPYING.LIB.
  21. // If not, write to the Free Software Foundation, Inc.,
  22. // 675 Mass Ave, Cambridge, MA 02139, USA.
  23. // 
  24. // NORA is an experimental inference-based software development
  25. // environment. Contact nora@ips.cs.tu-bs.de for details.
  26.  
  27. #include "std.vsl"
  28. #include "slopes.vsl"
  29.  
  30. // Version
  31. tree_version() = "$Revision: 1.2 $";
  32.  
  33. // Baumfunktionen
  34.  
  35. // 1. Vertikale Baeume
  36.  
  37. // Verhaeltnis Hoehe zu Breite (hier: (1:10))
  38.  
  39. treeheight(width) = vspace(square(width)) / 10;
  40.  
  41. // branches zeichnet die Verbindungen von der Wurzel zu den Soehnen.
  42. // branches gibt einen Kasten der Breite hroot * 2 und der Hoehe height 
  43. // zurueck.
  44. // Von der Mitte der oberen Kante von hsum + box/2 hin zur Mitte der 
  45. // oberen Kante des Kastens ist eine Linie gezogen.
  46.  
  47. vbranch(height, hroot, hsum, hbox2) =
  48. ( height & 
  49.   if hsum & hbox2 < hroot then
  50.         // box in linker Haelfte
  51.     hsum & hbox2 & rise() & hroot
  52.   elsif hsum & hbox2 > hroot then
  53.         // box in rechter Haelfte
  54.     hroot & fall() & hspace(hroot * 2 - hsum - hbox2)
  55.   else
  56.     // box in der Mitte
  57.     hcenter(vrule())
  58.   fi
  59. );
  60.  
  61. vbranches(height, hroot, hsum, box) = 
  62.   vbranch(height, hroot, hsum, hspace(box)/2);
  63.  
  64. vbranches(height, hroot, hsum, box, ...) = 
  65.   vbranches(height, hroot, hsum, box) 
  66. ^ vbranches(height, hroot, hsum & hspace(box), ...);
  67.  
  68.  
  69. // vtree(soehne...) verbindet eine Wurzel mit Soehnen. Die Kanten
  70. // enden jeweils in der Mitte der oberen Kante des Sohnes.
  71.  
  72. _vtree(align, ...) = 
  73.   vbranches(treeheight(hspace(align)), hspace(align)/2, 0, ...)
  74. | hcenter(align);
  75.  
  76. vtree(root) = root;
  77. vtree(root, ...) = 
  78.   hcenter(root) 
  79. | _vtree(halign(...), ...);
  80.  
  81.  
  82.  
  83. // 2. Horizontale Baeume
  84.  
  85. // Das gleiche, nur um 90 Grad gedreht
  86.  
  87. treewidth(height) = hspace(square(height)) / 10;
  88.  
  89. hbranch(width, vroot, vsum, vbox2) =
  90. ( width | 
  91.   if vsum | vbox2 < vroot then
  92.     // box in oberer Haelfte
  93.     vsum | vbox2 | rise() | vroot
  94.   elsif vsum | vbox2 > vroot then
  95.     // box in unterer Haelfte
  96.     vroot | fall() | vspace(vroot * 2 - vsum - vbox2)
  97.   else 
  98.     // box in der Mitte
  99.     vcenter(hrule())
  100.   fi
  101. );
  102.  
  103. hbranches(width, vroot, vsum, box) = 
  104.   hbranch(width, vroot, vsum, vspace(box)/2);
  105.  
  106. hbranches(width, vroot, vsum, box, ...) = 
  107.   hbranches(width, vroot, vsum, box) 
  108. ^ hbranches(width, vroot, vsum | vspace(box), ...);
  109.  
  110. _htree(align, ...) = 
  111.   hbranches(treewidth(vspace(align)), vspace(align)/2, 0, ...)
  112. & vcenter(align);
  113.  
  114. htree(root) = root;
  115. htree(root, ...) = 
  116.   vcenter(root) 
  117. & _htree(valign(...), ...);
  118.